package com.by.shop.product.controller;

import com.alibaba.fastjson.JSON;
import com.by.shop.common.entity.Product;
import com.by.shop.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("product")
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping("findbyid/{pid}")
    public Product findById(@PathVariable Integer pid) {
        Product product = productService.findByPid(pid);
        log.info("查询商品：" + JSON.toJSONString(product));
        return product;
    }
}
